import { Browser } from "../services/browser.s.js";
import { Bti } from "../services/bti.s.js";
import { logger } from "../utils/logger.js";
import readline from "readline";
const BrowserInstance = new Browser();
export const browserControllers = {
  async openBrowser(req, res) {
    try {
      await BrowserInstance.open();
      res.status(201).json({
        success: true,
        data: "成功打开 ",
      });
    } catch (error) {
      logger.error(error);
    }
  },
};

async function init() {
  await browserControllers.openBrowser()
  const BtiInstance = new Bti(BrowserInstance);
  // 创建 readline 接口
  const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
  });
  // 提示用户输入
  rl.question('/n请输入内容: ', (input) => {
    if (input) {
      logger.info("输入了")
      BtiInstance.openWeb()
    }
  });
}
init()
